package com.qf.myrbac.sys.controller;

import com.qf.myrbac.sys.entity.SysUser;
import com.qf.myrbac.sys.service.SysUserService;
import com.qf.myrbac.utils.PageVo;
import com.qf.myrbac.utils.ResultMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 系统用户 前端控制器
 * </p>
 *
 * @author 徐英海
 * @since 2022-10-27
 */
@RestController
@RequestMapping("/sys/user")
@Slf4j
public class SysUserController extends AbstractController {
    @Autowired
    private SysUserService userService;

    @GetMapping("/info")
    public ResultMap info() {
        return ResultMap.ok().put("user", getUser());
    }

    @RequiresPermissions("sys:user:list")//权限注解
    @GetMapping("/list")
    public ResultMap list(@RequestParam Map<String, Object> params) {
        PageVo<SysUser> pageVo = userService.queryUserByPage(params);
        return ResultMap.ok().put("page", pageVo);
    }
}
